﻿@model FlexFlow.Model.WorkFlowTask


@{
    string formId = Model.SendData[FlexFlow.Model.SystemTaskDataKey.UserFormId].ToString();
    bool needSignOption = Model.SendData.ContainsKey(FlexFlow.Model.SystemTaskDataKey.NeedSignOption) ? (bool)Model.SendData[FlexFlow.Model.SystemTaskDataKey.NeedSignOption] : false;
    Guid? submitFormGuid = Model.SendData.ContainsKey(FlexFlow.Model.SystemTaskDataKey.TaskFormId) ? (Guid?)(Model.SendData[FlexFlow.Model.SystemTaskDataKey.TaskFormId]) : null;
}
<link href="~/Assets/css/jquery-ui-1.10.3.custom.min.css" rel="stylesheet" />
<link href="~/Assets/css/tagmanager.css" rel="stylesheet" />
<link href="~/Assets/css/typeahead.css" rel="stylesheet" />
<script src="~/Assets/js/jquery.form.js"></script>
<script src="~/assets/js/jquery.validate.min.js"></script>
<script src="~/Assets/js/typeahead.bundle.js"></script>
<script src="~/Assets/js/flexflow-controls.js"></script>
<script src="~/Assets/js/tagmanager.js"></script>
<script src="~/Assets/js/handlebars.js"></script>
<div class="row">
    <div class="form-horizontal">
        <div class="form-group">
            <div class="form-group">
                <label class="col-sm-3 control-label no-padding-right" for="name"> 用户表单： </label>
                <div class="col-sm-9">
                    <label class="btn btn-xs btn-danger tooltip-warning" data-rel="tooltip" data-placement="right" data-original-title="点击查看当前用户进入流程时使用的表单" onclick="viewForm('@formId')">
                        <i class="icon-undo bigger-110"></i>
                        查看表单
                        <i class="icon-arrow-right icon-on-right"></i>
                    </label>
                </div>
            </div>
            @if(submitFormGuid!=null)
            {
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="temp">审批表单:</label>
                    <div class="col-sm-9">
                        <input type="text" style="width:9em;" id="formSelector" name="submitForm" placeholder="请输入表单名称" class="input-medium tm-input tm-input-success tm-input-typeahead">
                    </div>
                </div>
            }
            @if(needSignOption)
            {
                <div class="form-group">
                    <label class="col-sm-3 control-label no-padding-right" for="@FlexFlow.Model.SystemTaskDataKey.NeedSignOption"> 意见 </label>
                    <div class="col-sm-9">
                        <input type="text" id="@FlexFlow.Model.SystemTaskDataKey.NeedSignOption" name="@FlexFlow.Model.SystemTaskDataKey.NeedSignOption" placeholder="请输入意见" class="col-xs-12 col-sm-9">
                    </div>
                </div>
            }
        </div>
        <div class="col-md-offset-3 col-md-9">
            <button class="btn btn-info" onclick="submitApprove(true)">
                <i class="icon-ok bigger-110"></i>
                同意
            </button>

            &nbsp; &nbsp; &nbsp;
            <button class="btn" onclick="submitApprove(false)">
                <i class=" icon-undo bigger-110"></i>
                拒绝
            </button>
        </div>
    </div>
    <script>
        function viewForm(formId) {
            $.ajax({
                type: 'GET',
                url: "/WorkFlowForm/Form?readOnly=true&formId=" + formId,
                success: function (data) {
                    bootbox.dialog({
                        message: data,
                        title: "浏览表单"
                    });
                }
            });
        }
        @if (submitFormGuid != null)
	    {
		     @: initTempList("#formSelector", null, "@submitFormGuid", {
             @:   hiddenTagListName: "formId",
             @:   maxTags: 1
             @: });
	    }
        function submitApprove(accept) {
            doOperation({
                'url': '/FFEUserAPI/SubmitApprovalTask',
                'data': {
                    'taskId' : '@Model.Identity',
                    'accepted': accept
                    @if(needSignOption)
                    {
                        @: ,'@FlexFlow.Model.SystemTaskDataKey.NeedSignOption': $("#@FlexFlow.Model.SystemTaskDataKey.NeedSignOption").val()
                    }
                },
                'success': function (d) {
                    bootbox.alert("操作成功！");
                    row.remove().draw(false)
                }
            });
        }
    </script>
</div>
